package com.perkinelmer.housecall.client;

import java.util.ArrayList;
import java.util.List;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.perkinelmer.housecall.client.activities.capture.Capture;
import com.perkinelmer.housecall.client.activities.capture.CaptureActivity;
import com.perkinelmer.housecall.client.activities.capture.CaptureLibrary;
import com.perkinelmer.housecall.client.activities.capture.impl.AudioCapture;
import com.perkinelmer.housecall.client.activities.capture.impl.ImageCapture;
import com.perkinelmer.housecall.client.activities.capture.impl.VideoCapture;
import com.perkinelmer.housecall.client.activities.capture.impl.VitalsCapture;
import com.perkinelmer.housecall.client.activities.patientdetails.PatientDetailsActivity;
import com.perkinelmer.housecall.client.activities.selectpatient.SelectPatientActivity;
import com.perkinelmer.housecall.client.activity.Activity;
import com.perkinelmer.housecall.client.activity.ActivityLibrary;
import com.perkinelmer.housecall.client.activity.ActivityManager;

public class Housecall implements EntryPoint {

	public void onModuleLoad() {
		
		Panel activityPanel = new SimplePanel();
		
		activityPanel.setHeight("800px");
		activityPanel.setWidth("480px");
		
		RootPanel.get().add(activityPanel);
		
		ActivityManager manager = new ActivityManager(activityPanel);
		ActivityLibrary library = new StandardActivityLibrary(manager);
		manager.setLibrary(library);
		
		manager.gotoActivity(SelectPatientActivity.ID);
	}
	
	private class StandardActivityLibrary implements ActivityLibrary {

		private final ActivityManager manager;
		public StandardActivityLibrary(ActivityManager manager) {
			this.manager = manager;
		}
		
		@Override
		public List<Activity<?>> getActivities() {
			List<Activity<?>> activities = new ArrayList<Activity<?>>();
			
			StandardCaptureLibrary standardLib = new StandardCaptureLibrary();
			PatientDetailsActivity detailsActivity = new PatientDetailsActivity(standardLib, manager);
			
			activities.add(new CaptureActivity(standardLib, detailsActivity, manager));
			activities.add(new SelectPatientActivity(manager));
			activities.add(detailsActivity);
			
			return activities;
		}
	}
	
	private class StandardCaptureLibrary implements CaptureLibrary {

		@Override
		public List<Capture> getCaptures() {
			List<Capture> captures = new ArrayList<Capture>();
			captures.add(new ImageCapture());
			captures.add(new AudioCapture());
			captures.add(new VideoCapture());
			captures.add(new VitalsCapture());
			
			return captures;
		}
		
	}
}
